﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MessagePublishers
{
    using Domain.OAuth;
    using ECommon.Components;
    using ECommon.IO;
    using ENode.Infrastructure;
    using Messages;

    [Component]
    public class OAuthMessagePublisher :
        IMessageHandler<SignInRejectedEvent>
    {

        private readonly IMessagePublisher<IApplicationMessage> _messagePublisher;
        public OAuthMessagePublisher(IMessagePublisher<IApplicationMessage> messagePublisher)
        {
            _messagePublisher = messagePublisher;
        }


        public Task<AsyncTaskResult> HandleAsync(SignInRejectedEvent evnt)
        {
            return _messagePublisher.PublishAsync(new SignInRejectedMessage
            {
                Account = evnt.Account,
                Ip = evnt.Ip
            });
        }

    }
}
